<!DOCTYPE html>
<html lang="en">
<head>
    <title>WebSocket聊天宝登录</title>
    <meta charset="UTF-8">
</head>
<body>
<div class="logo_box">
    <button onclick="sendMessage()">发送</button>
</div>
<script>
    function sendMessage() {
        console.log(`我被调用了。。。。` + document.hasFocus())
        if(window.Notification && Notification.permission !== "denied") {
            Notification.requestPermission(function(status) {
                if (!document.hasFocus()) {
                    var notice_ = new Notification('新的消息', { body: '您有新的消息'});
                    notice_.onclick = function() {//单击消息提示框，进入浏览器页面
                        window.focus();
                    }
                }

            });
        }
    }
</script>
</body>
</html>